﻿using Demo.HangfireIntergation.Jobs;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;

namespace Demo.HangfireIntergation.Controllers
{
    /// <summary>
    /// 任务管理
    /// </summary>
    [ApiController]
    [Route("api/tasks")]    
    public class TasksManagerController : AbpController
    {
        public readonly MyJob1 _myjob1;

        public TasksManagerController(MyJob1 myjob1)
        {
            _myjob1 = myjob1;
        }

        /// <summary>
        /// 启动任务
        /// </summary>
        /// <returns></returns>
        [HttpPost("start")]
        public async Task<string> StartTaskAsync()
        {
            // 启动任务
            await _myjob1.StartAsync();
            return "任务已启动";
        }

        /// <summary>
        /// 停止任务
        /// </summary>
        /// <returns></returns>
        [HttpPost("stop")]
        public async Task<string> StopTaskAsync()
        {
            await _myjob1.StopAsync();
            return "任务已停止";
        }



    }
}
